import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * la clase menu donde se accede al juego , menu y los records
 * 
 * @author (Carlos Andrés Olea Reyes) 
 */
public class menu extends ScrollWorld
{
    private GreenfootSound menuSound= new GreenfootSound("menu sound.mp3");
    private GreenfootSound button= new GreenfootSound("button-1.mp3");
    private botonI btni=new botonI();
    private BotonA btna=new BotonA();
    private botonR btnR=new botonR();
    private buttonC btnC=new buttonC();
    
    
    /**
     * Crea el menu del juego 
     * 
     */
    public menu()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1,600,400); 
        
        prepare();
        
    }
    
    public void act()
    {
        
        menu();      
        
    }
    
    
    /**
     * Este metodo crea los botones del juego para que puedan ser accedidos mediante un clic
     * 
     */
    public void menu()
    {
        MouseInfo m = Greenfoot.getMouseInfo();
        button.setVolume(40);
        menuSound.playLoop();
        if(Greenfoot.mousePressed(btni))
         {
          button.play();
          menuSound.stop();   
          Greenfoot.setWorld(new World1());

         }
        if(Greenfoot.mousePressed(btna))
         {
          button.play();
          menuSound.stop();
             Greenfoot.setWorld(new Ayuda());
          
         }
        if(Greenfoot.mousePressed(btnR))
         {
             button.play();   
             menuSound.stop();
             Greenfoot.setWorld(new Records());
          
         } 
         if(Greenfoot.mousePressed(btnC))
         {
             button.play();   
             menuSound.stop();
             Greenfoot.setWorld(new Credits());
          
         } 
    }
    
    
    /**
     * Prepare the world for the start of the program. That is: create the initial
     * objects and add them to the world.
     */
    private void prepare()
    {
        addObject(btni, 310, 260);
        addObject(btna, 440, 320);
        addObject(btnR, 160, 320);
        addObject(btnC, 310, 320);
    }
    
    
    /**
     * Detiene la musica si es que se presiona el boton pause de greenfoot
     */
    public void stopped()
    {
    menuSound.pause();
    }
}
